/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import ru.jSkyRoom.interfaces.major.DialogBranch;
import ru.jSkyRoom.interfaces.major.DialogView;
import ru.jSkyRoom.interfaces.major.Quest;
import skyproc.DLVW;
import skyproc.FormID;

/**
 *
 * @author Rakev
 */
public class DialogViewBridge extends MajorBridge<DLVW> implements DialogView {

    public DialogViewBridge(DLVW adapting) {
        super(adapting);
    }

    @Override
    public Quest getQuest() {
        FormID id = getRawObject().getQuest();
        return getFinderFactory().createQuestFinder().find(id);
    }

    @Override
    public void setQuest(Quest quest) {
        FormID id = getIdProducer().produce(quest);
        getRawObject().setQuest(id);
    }

    @Override
    public Collection<DialogBranch> getBranches() {
        Collection<FormID> ids = getRawObject().getBranches();
        Collection<DialogBranch> result = getFinderFactory().createDialogBranchFinder().find(ids);
        return Collections.unmodifiableCollection(result);
    }

    @Override
    public void addBranch(DialogBranch dialogBranch) {
        FormID id = getIdProducer().produce(dialogBranch);
        getRawObject().addBranch(id);
    }

    @Override
    public void removeBranch(DialogBranch dialogBranch) {
        FormID id = getIdProducer().produce(dialogBranch);
        getRawObject().removeBranch(id);
    }
}
